#include <complex>
#include <x86intrin.h>
#include <iostream>
#define N 10000
using namespace std;
void mul(complex<double> *x, complex<double> *y)
{
    __m256d tx, ty, r;
    tx = _mm256_loadu_pd((double *) (x));
    ty = _mm256_loadu_pd((double *) (y));
    r = _mm256_permute_pd(ty, 5) * _mm256_permute_pd(tx, 15);
    _mm256_storeu_pd((double *) (x), _mm256_fmaddsub_pd(ty, _mm256_movedup_pd(tx), r));
}

int main()
{
    complex<double> x[2], y[2];
    x[0] = complex<double>(1, 0);
    x[1] = complex<double>(-1, 0);
    y[0] = complex<double>(0, 1);
    y[1] = complex<double>(0, -1);
    for (int j = 0; j < N * N; j++) {
        mul(x,y);
        // x[0] = x[0] * y[0];
        // x[1] = x[1] * y[1];
    }
    cout << x[0] << '\t' << x[1] << endl;
    return 0;
}